#+TITLE: Threading Macro Usage
#+AUTHOR: Zelphir Kaltstahl
#+STARTUP: content indent align inlineimages hideblocks entitiesplain nologdone nologreschedule nologredeadline nologrefile
#+TODO: TODO INPROGRESS | DONE
#+DATE: [2021-05-19 Wed]
#+LANGUAGE: en
#+PRIORITIES: A E E
#+KEYWORDS: GNU Guile Scheme macro usage

The hygienic syntax rules macro for threading / pipeline / chain allows for
leaving out the threaded argument in function calls. ~pipe-left~ is used as
follows:

#+NAME: pipe-left-usage
#+begin_src scheme :results output verbatim replace drawer
(define-syntax ->
  (syntax-rules ()
    [(-> exp) exp]
    [(-> exp ... (op args ...))
     (op (-> exp ...) args ...)]))


(simple-format (current-output-port)
               "~s\n"
               (-> 123
                   (* 2)
                   (- 6)
                   (/ 4)
                   (number->string)))
#+end_src

#+RESULTS: pipe-left-usage
:results:
"60"
While executing meta-command:
Wrong type to apply: #<unspecified>
scheme@(guile-user)>
:end:

As one can see each function call in the macro call is missing the threaded
argument. It will be put in the left-most position automatically by the macro,
which rewrites the function calles into valid calls.
